var api = require('./api.js')
var request = require('./request.js')

 // 登录
function login(params) {
  return request.requestApi({
    url: api.login,
    data: params,
    method: 'POST'
  })
}

// 退出
function logout(params) {
  return request.requestApi({
    url: api.logout,
    data: params,
    method: 'POST',
    header: {
      'Content-type': 'application/json',
      'Authorization': wx.getStorageSync("token")
    },
  })
}

// 获取题目信息
function getTopic(params) {
  return request.requestApi({
    url: api.getTopic,
    data: params,
    method: 'POST',
    header: {
      'Content-type': 'application/json',
      'Authorization': wx.getStorageSync("token")
    },
  })
}

// 判断答题
function judgeTopicAnswer(params) {
  return request.requestApi({
    url: api.judgeTopicAnswer,
    data: params,
    method: 'POST',
    header: {
      'Content-type': 'application/json',
      'Authorization': wx.getStorageSync("token")
    },
  })
}

// 设置用户信息
function setUserInfo(params) {
  return request.requestApi({
    url: api.setUserInfo,
    data: params,
    method: 'POST',
    header: {
      'Content-type': 'application/json',
      'Authorization': wx.getStorageSync("token")
    },
  })
}

module.exports = {
  login,
  logout,
  getTopic,
  judgeTopicAnswer,
  setUserInfo
}